package com.plugin.manage.test;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class EncryptPwdDemo {

    public static void main(String[] args) {
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        String rawPassword = "admin123";
        String encodedPassword = passwordEncoder.encode(rawPassword);
        System.out.println("Encoded password: " + encodedPassword);

        System.out.println(isPasswordValid("admin123","$2a$10$kxJwjaSQcdEyQpp6BHs7wecvy74pwMmfQmt7xW7W/eDNzUvJ3BKGO"));

    }


    public static boolean isPasswordValid(String rawPassword, String encodedPassword) {
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        return passwordEncoder.matches(rawPassword, encodedPassword);
    }
}